`
https://leetcode.cn/problems/minimum-difference-between-highest-and-lowest-of-k-scores/
`

/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var minimumDifference = function (nums, k) {
  const n = nums.length
  nums.sort((a, b) => a - b)

  let res = Infinity
  for (let i = 0; i < n - k + 1; i++) {
    res = Math.min(res, nums[i + k - 1] - nums[i])
  }

  return res === Infinity ? 0 : res
};